/*
 * MultiplayerClientModePanel.java
 *
 * Created on January 28, 2007, 11:50 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.sf.iSnake.UI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import net.sf.iSnake.configuration.iSnakeConfiguration;

/**
 *
 * @author Jitendra
 */
public class MultiplayerClientModePanel extends JPanel  {
    
    private static iSnakeConfiguration conf;
    private JPanel configOptionPanel;
    
    private JButton playNowButton;
    private JButton goBackButton;
    
    private JTextField serverNameField;
    private JTextField serverPortField;
    private JTextField playerNameField;
    private JComboBox playerSnakeColorCombo;
    
    private Font fontLabel;
    private Font fontHeader;
    
    private static String panelName = "MultiplayerClientModePanel";             // Required by CardManagerLayout to refer to this panel
    
    /** Creates a new instance of MultiplayerClientModePanel */
    public MultiplayerClientModePanel(iSnakeConfiguration conf) {

        this.conf = conf;
        setLayout(new BorderLayout());
        setBackground(conf.MultiplayerModeBackgroundColor);
        fontLabel = new Font(conf.MultiplayerModeFont,Font.PLAIN,conf.MultiplayerModeFontSize);
        fontHeader = new Font(conf.MultiplayerModeHeaderFont,Font.BOLD,conf.MultiplayerModeHeaderFontSize);
        
        configOptionPanel = new JPanel(new GridLayout(6,2,10,20));
        setPreferredSize(new Dimension(300,260));
        configOptionPanel.setFont(fontLabel);
        configOptionPanel.setBackground(conf.MultiplayerModeBackgroundColor);
        
        JLabel serverNameLabel = conf.getLabelForUIPanel(new JLabel("Server Name"));
        configOptionPanel.add(serverNameLabel);
        
        setServerNameField(conf.getTextFieldForUIPanel(new JTextField("tlm")));
        configOptionPanel.add(getServerNameField());
        
        JLabel serverPortLabel = conf.getLabelForUIPanel(new JLabel("Server Port"));
        configOptionPanel.add(serverPortLabel);
        
        setServerPortField(conf.getTextFieldForUIPanel(new JTextField("9669", 8)));
        configOptionPanel.add(getServerPortField());
        
        JLabel playerNameLabel = conf.getLabelForUIPanel(new JLabel("Player Name"));
        configOptionPanel.add(playerNameLabel);
        
        setPlayerNameField(conf.getTextFieldForUIPanel(new JTextField("sata",30)));
        configOptionPanel.add(getPlayerNameField());
        
        JLabel playerSnakeColorLabel = conf.getLabelForUIPanel(new JLabel("Snake Color"));
        configOptionPanel.add(playerSnakeColorLabel);
        
        setPlayerSnakeColorCombo(new JComboBox());
        getPlayerSnakeColorCombo().setEditable(false);
        getPlayerSnakeColorCombo().addItem(new Color(255,128,0));
        getPlayerSnakeColorCombo().addItem(new Color(255,0,0));
        getPlayerSnakeColorCombo().addItem(new Color(0,255,0));
        getPlayerSnakeColorCombo().addItem(new Color(0,0,255));
        getPlayerSnakeColorCombo().addItem(new Color(255,128,128));
        
        configOptionPanel.add(getPlayerSnakeColorCombo());
        
        JLabel iSnakeIntelligenceLabel = conf.getLabelForUIPanel(new JLabel("iSnake Intelligence"));
        configOptionPanel.add(iSnakeIntelligenceLabel);

        JComboBox iSnakePresence = new JComboBox();
        iSnakePresence.setEditable(false);
        iSnakePresence.addItem("don't like iSnake");
        iSnakePresence.addItem("intelligence of a kid");
        iSnakePresence.addItem("highly intelligent");
        iSnakePresence.addItem("eXtreme intelligence");
        configOptionPanel.add(iSnakePresence);
        
        goBackButton = conf.getPanelChangeButtonForUIPanel(new JButton("go back to main menu"));
        goBackButton.setMnemonic('A');
        goBackButton.setActionCommand("from_MultiplayerClientModePanel_to_MainMenu");
        configOptionPanel.add(goBackButton);
        
        playNowButton = conf.getPanelChangeButtonForUIPanel(new JButton("let me play now"));
        playNowButton.setMnemonic('N');
        playNowButton.setActionCommand("from_MultiplayerClientModePanel_to_GameArea");
        configOptionPanel.add(playNowButton);
        
        // used for proper placement of components
        JLabel dummyNorth = new JLabel("");
        dummyNorth.setPreferredSize(new Dimension(800,140));        // height of logo=120px and 20px for padding purpose
        
        // used for proper placement of components
        JLabel dummySouth = new JLabel("");
        dummySouth.setPreferredSize(new Dimension(800,200));        // height of logo=120px and 20px for padding purpose

        // used for proper placement of components
        JLabel dummyWest = new JLabel("");
        dummyWest.setPreferredSize(new Dimension(200,400));        // height of logo=120px and 20px for padding purpose
        
        // used for proper placement of components
        JLabel dummyEast = new JLabel("");
        dummyEast.setPreferredSize(new Dimension(200,400));        // height of logo=120px and 20px for padding purpose
        
        add(configOptionPanel,BorderLayout.CENTER);
        add(dummyNorth,BorderLayout.NORTH);
        add(dummySouth,BorderLayout.SOUTH);
        add(dummyWest,BorderLayout.WEST);
        add(dummyEast,BorderLayout.EAST);
    }
    
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        g.drawImage(conf.getISnakeLogoSmall(),10,10,null);
        g.setColor(conf.MultiplayerModeHeaderColor);
        g.setFont(fontHeader);
        g.drawString("Multiplayer Client Mode",240,100);
    }

    public static String getPanelName() {
        return panelName;
    }

    public static void setPanelName(String aPanelName) {
        panelName = aPanelName;
    }

    public JButton getPlayNowButton() {
        return playNowButton;
    }

    public JButton getGoBackButton() {
        return goBackButton;
    }

    public JTextField getServerNameField() {
        return serverNameField;
    }

    public void setServerNameField(JTextField serverNameField) {
        this.serverNameField = serverNameField;
    }

    public JTextField getServerPortField() {
        return serverPortField;
    }

    public void setServerPortField(JTextField serverPortField) {
        this.serverPortField = serverPortField;
    }

    public JTextField getPlayerNameField() {
        return playerNameField;
    }

    public void setPlayerNameField(JTextField playerNameField) {
        this.playerNameField = playerNameField;
    }

    public JComboBox getPlayerSnakeColorCombo() {
        return playerSnakeColorCombo;
    }

    public void setPlayerSnakeColorCombo(JComboBox playerSnakeColorCombo) {
        this.playerSnakeColorCombo = playerSnakeColorCombo;
    }
}